<template>
  <div>
    <el-card style="min-width: 1200px">
      <div class="tableSelectWrap">
        <el-form ref="transferForm" :model="commandForm" label-width="100px">
          <el-row>
            <el-col :span="7">
              <el-form-item label="选择时间" prop="date">
                <el-date-picker
                  :default-time="['00:00:00', '23:59:59']"
                  v-model="commandForm.date"
                  style="width: 100%"
                  type="datetimerange"
                  start-placeholder="开始时间"
                  end-placeholder="结束时间"
                  value-format="yyyy-MM-dd HH:mm:ss"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="7" :offset="1">
              <el-form-item label="收款方" prop="inMemberNo">
                <el-input
                  v-model="commandForm.inMemberNo"
                  placeholder="请输入收款方"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="7" :offset="1">
              <el-form-item label="付款方" prop="outMemberNo">
                <el-input
                  v-model="commandForm.outMemberNo"
                  placeholder="请输入付款方"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="7">
              <el-form-item label="转账状态" prop="status">
                <el-select
                  v-model="commandForm.status"
                  style="width: 100%"
                  clearable
                  placeholder="请选择转账状态"
                >
                  <el-option label="所有" value=""></el-option>
                  <el-option label="处理成功" value="success"></el-option>
                  <el-option label="处理中" value="processing"></el-option>
                  <el-option label="处理失败" value="fail"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="7" :offset="1" style="min-width: 170px">
              <el-button
                class="width120"
                @click="
                  resetForm('transferForm');
                "
                >重置</el-button
              >
              <el-button type="primary" class="width120" @click="
                  () => {
                    this.dataForm = JSON.parse(
                      JSON.stringify(this.commandForm)
                    );
                    this.handleQuery();
                  }
                "
                >查询</el-button
              >
            </el-col>
          </el-row>
        </el-form>
      </div>
    </el-card>
    <el-card style="margin-top: 15px; min-width: 1200px">
      <div class="switch">
        <el-switch v-model="isFixedTableH" inactive-text="固定表头"></el-switch>
        <div>
          <el-button type="primary" class="width120" @click="createTransferFn">创建余额转账</el-button>
        </div>
      </div>
      <el-table :data="dataList" :height="fixedTableHeight">
        <template slot="empty">
          <el-empty
            :image="require('@/assets/imgs/middleWork/k1.png')"
            :image-size="80"
            description="暂无相关数据"
          ></el-empty>
        </template>
        <el-table-column
          show-overflow-tooltip
          prop="gmtCreated"
          align="center"
          label="转账时间"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.gmtCreated ? scope.row.gmtCreated : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="outMemberNo"
          width="320"
          align="center"
          label="付款方"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.outMemberNo ? scope.row.outMemberNo : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="inMemberNo"
          width="320"
          align="center"
          label="收款方"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.inMemberNo ? scope.row.inMemberNo : "-" }}
            </div>
          </template>
        </el-table-column>
      
        <el-table-column
          show-overflow-tooltip
          prop="fmtTransAmt"
          sortable
          align="center"
          label="转账金额/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.fmtTransAmt ? scope.row.fmtTransAmt : "0.00" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="fmtFeeAmt"
          align="center"
          label="用户手续费/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
            {{ scope.row.fmtFeeAmt ? scope.row.fmtFeeAmt : "0.00" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="statusName"
          align="center"
          label="转账状态"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.statusName?scope.row.statusName:"" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="act"
          align="center"
          label="操作"
        >
          <!-- <template slot-scope="scope">
            <el-button type="text" @click="handleDetails(scope.row)"
              >详情</el-button
            >
          </template> -->
          <div>-</div>
        </el-table-column>
      </el-table>
    </el-card>
    <el-pagination
      layout="prev, pager, next, sizes, jumper"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="pageSize"
      :current-page="pageNum"
      :total="total"
      @current-change="pageCurrentChangeHandle"
      @size-change="pageSizeChangeHandle"
    >
    </el-pagination>
    <detail-drawer
      :drawer.sync="drawer"
      :info="detailsInfo"
      :activeKey="activeKey"
    ></detail-drawer>
  </div>
</template>

<script>
import detailDrawer from "./detailDrawer.vue";
import mixin from "@/mixins/mixin";
export default {
  name: "transferRecord",
  mixins: [mixin],
  components: {
    detailDrawer,
  },
  data() {
    return {
      drawer: false,
      activeKey: "1",
      mixinViewModuleOptions: {
        getDataListURL: "/api/merchant/settleBalancePay/searchByPage",
        createdIsNeed: false,
      },
      commandForm: {
        date: [],
        inMemberNo: "",
        outMemberNo: "",
        status: "",
      },
    };
  },
  created(){
    this.dataForm = JSON.parse(JSON.stringify(this.commandForm));
    this.handleQuery()
  },
  watch: {
    "$store.state.testLine": {
      handler() {
        if (this.$route.name == this.$options.name) {
          this.handleQuery()
        }
      },
    },
    deep: true,
  },
  methods: {
    handleDetails(row) {
      this.$http
            .get(`/api/merchant/balanceCharge/get?id=${row.id}`)
            .then((res) => {
              if (res.code === "0000") {
                this.detailsInfo = res.data;
                this.drawer = true;
              }
            });
    },
    handleQuery() {
      if (this.dataForm.date && this.dataForm.date.length) {
        this.dataForm.gmtCreatedBegin = this.dataForm.date[0];
        this.dataForm.gmtCreatedEnd = this.dataForm.date[1];
      } else {
        this.dataForm.gmtCreatedBegin = "";
        this.dataForm.gmtCreatedEnd = "";
      }
      this.getDataList();
    },
    createTransferFn(){
this.$router.push('/account/transfer_reset')
    },
  },
};
</script>

<style scoped lang="scss">
.switch {
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
}
.ml {
  margin-left: 50px;
}
.search {
  position: absolute;
  right: 0;
  top: -164px;
}
</style>
